package com.zlfund.cat.zjgsmk.ui.base;

import android.app.Application;
import android.content.Context;

import com.zlfund.cat.zjgsmk.controller.HasLoginHelper;
import com.zlfund.cat.zjgsmk.controller.ILoginStateService;
import com.zlfund.cat.zjgsmk.controller.NoLoginHelper;
import com.zlfund.cat.zjgsmk.ui.user.UserManager;

/**
 * Created by chenj
 * Created on 2017/8/15
 */

public class ZApplication extends Application {

    public static int SCREEN_HEIGHT;
    public static int SCREEN_WIDTH;
    public static ZApplication mContext;
    public ILoginStateService mLoginService;

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = this;
        initDeviceSize();
        if (UserManager.isLogin()){
            mLoginService = new HasLoginHelper();
        }else {
            mLoginService = new NoLoginHelper();
        }
    }

    private static void initDeviceSize() {
        SCREEN_HEIGHT = mContext.getResources().getDisplayMetrics().heightPixels;
        SCREEN_WIDTH = mContext.getResources().getDisplayMetrics().widthPixels;
    }

    public void setLoginService(ILoginStateService service){
        mLoginService = service;
    }

    public ILoginStateService getLoginService(){
        return mLoginService;
    }
}
